
var File = {
	dialog_add_: function (url, title, xy) {
		var result = Common.result();
		$('#dialog_add').dialog('option', 'buttons', {
			"关闭": function() {
				$(this).dialog("close");
			},

			"上传": function() {
				if (!confirm("确认是否提交？")) {
					return false;
				}
				
				$('#userfile').uploadify('upload');
			}
		});

		dialog_add(url, title, xy);
	},
	
	popup: function (e, p2, id) {
		$.cookie('id_', id);

		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'mogilefs.php?do=File.edit&id=' + id + p2;
		var c2 = 'mogilefs.php?do=File.view&fid=' + id;
		
		var a1 = ['编辑信息', 'url', 'File.dialog_edit_', '650x400'];
		var a2 = ['查看信息', 'url', 'Common.dialog_view_', '600x400'];

		var s = c1 + ", " + c2;

		return popup(e, [a1, a2], s);
	},

	/**
	 * 编辑
	 */
	dialog_edit_: function (url, title, xy) {
		var result = Common.result();
		$('#dialog_edit').dialog('option', 'buttons', {
			"关闭": function() {
				$(this).dialog("close");
			},

			"修改": function() {
				if (!confirm("确认是否提交？")) {
					return false;
				}

				var form = $("#form_edit")[0];

				var body = {};
				
				body.dkey1 = form.dkey1.value;
				body.dkey2 = form.dkey2.value;

				$(this).dialog("close");

				var url = 'mogilefs.php?do=File.editPost';
				var p2 = $.cookie('p2');
				if (p2 != null) {
					url += p2;
				}

				$.post(url, body, function(data) {
					$(result).html(data);
				});
			}
		});

		dialog_edit(url, title, xy);
	}

};
